package com.qianfeng.openapi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qianfeng.openapi.mapper.TokenMapper;
import com.qianfeng.openapi.pojo.Token;
import com.qianfeng.openapi.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional//事务
public class TokenServiceImpl implements TokenService {
    @Autowired
    private TokenMapper tokenMapper;
    @Override
    public PageInfo<Token> selectAll(int page, int limit, Token token) {
        PageHelper.startPage(page,limit);
        List<Token> allToken = tokenMapper.getAllToken(token);
        PageInfo<Token> pageInfo = new PageInfo<>(allToken);
        return pageInfo;
    }

    @Override
    public Token selectTokenById(Integer id) {
        return tokenMapper.selectTokenById(id);
    }

    @Override
    public void deleteTokenByIds(int[] ids) {
        tokenMapper.deleteToken(ids);
    }

    @Override
    public void updateToken(Token token) {
        tokenMapper.updateToken(token);
    }
}
